﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Jzy.Core.Common.Basic;
using FortuneHeavenBAL;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeaven.Admin.Common
{
    public abstract class PageBase : System.Web.UI.Page
    {
        protected override void OnPreLoad(EventArgs e)
        {
            base.OnPreLoad(e);
            //CheckUser();
        }

        public abstract string PageID
        {
            get;
        }   

        public bool CheckUser()
        {
            if (AuthorityCenter.CheckLogin() && AuthorityCenter.CheckPermission(PageID))
            {
                return true;
            }
            return false;
        }

        public void TransferErrorPage()
        {
            Response.Redirect(string.Format("{0}{1}",GlobalVar.WebAppPath,"Error.htm"));
        }

        protected void ShowCurError(string message)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "error", string.Format("alert('{0}')", message),true);
        }

        public int GetInt(string value)
        {
            int k = 0;
            int.TryParse(value, out k);
            return k;
        }

        public string NavToUserInforByID(object userid)
        {
            return Page.ResolveUrl("~/Pages/GameManager/UserInforDetail.aspx?ID=") + userid.ToString() + "&Pre=" + this.Request.Url.OriginalString;
        }

        public string NavToUserInforByName(object accountname)
        {
            return Page.ResolveUrl("~/Pages/GameManager/UserInforDetail.aspx?Accounts=") + Server.UrlEncode( accountname.ToString()) + "&Pre=" + this.Request.Url.OriginalString;
        }
    }
}